package com.itheima.myiotest3;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) throws IOException {
        //需求：模拟实现登录
        //读取数据
        BufferedReader br = new BufferedReader(new FileReader("D:\\JAVAcode\\java_code\\Stream\\myio\\src\\com\\itheima\\myiotest3\\userInfo.txt"));
        String line = br.readLine();
        br.close();
        //进行拆分
        String[] arr = line.split("&");
        String[] arr1 = arr[0].split("=");
        String[] arr2 = arr[1].split("=");

        //定义正确答案
        String rightUserName = arr1[1];
        String rightPassWord = arr2[1];

        //进行数据输入
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入用户名");
        String username = sc.nextLine();
        System.out.println("请输入密码");
        String password = sc.nextLine();

        //判断是否正确
        if(username.equals(rightUserName)&&password.equals(rightPassWord)){
            System.out.println("登录成功");
        }else{
            System.out.println("登录失败");
        }
    }
}
